/**
 * @title CustomChooseDialog.java
 * @package com.esun.cheetah.view.custom
 * @description 
 * @author liugan
 * @date 2012-4-26
 * @copyright 深圳市易讯天空
 */
package com.esun.cheetah.view.custom;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.esun.cheetah.R;

/**
 * @title CustomChooseDialog
 * @description
 * @author liugan
 */
public class CustomChooseDialog extends Dialog {
	private Button mLeftButton;
	private Button mRightButton;
	private TextView mMessageText;
	private TextView mTitleText;
	private CharSequence mMessage;
	private View.OnClickListener mLeftListener;
	private View.OnClickListener mRightListener;
	private CharSequence mLeftText;
	private CharSequence mRightText;
	private CharSequence mTitle;

	/**
	 * @param context
	 */
	public CustomChooseDialog(Context context) {
		super(context, R.style.dialog);
		setContentView(R.layout.dialog_choose_view);
		mLeftButton = (Button) findViewById(R.id.btn_dialog_left);
		mRightButton = (Button) findViewById(R.id.btn_dialog_right);
		mMessageText = (TextView) findViewById(R.id.tv_dialog_message);
		mTitleText = (TextView) findViewById(R.id.tv_dialog_title);
	}

	@Override
	protected void onStart() {
		if (mTitle != null) {
			mTitleText.setText(mTitle);
		}
		if (mMessage != null) {
			mMessageText.setText(mMessage);
		}

		if (mLeftListener != null) {
			mLeftButton.setOnClickListener(mLeftListener);
		}
		if (mRightListener != null) {
			mRightButton.setOnClickListener(mRightListener);
		}
		if (mLeftText != null) {
			mLeftButton.setText(mLeftText);
		}
		if (mRightText != null) {
			mRightButton.setText(mRightText);
		}
	}

	public void setMessage(CharSequence message) {
		this.mMessage = message;
	}

	public void setOnLeftButtonClickListener(View.OnClickListener l) {
		this.mLeftListener = l;
	}

	public void setOnRightButtonClickListener(View.OnClickListener l) {
		this.mRightListener = l;
	}

	public void setLeftButtonText(CharSequence text) {
		this.mLeftText = text;
	}

	public void setRightButtonText(CharSequence text) {
		this.mRightText = text;
	}

	@Override
	public void setTitle(CharSequence title) {
		this.mTitle = title;
	}

}
